package cn.matrix42.potoo.format.json.parser;

public class Main {

    public static void main(String[] args) {

        JsonObject jsonObject = new JsonObject()
            .put("a", JsonLiteral.of(1))
            .put("b", JsonLiteral.of(12.0));

        JsonArray jsonArray = new JsonArray()
            .add(jsonObject)
            .add(jsonObject);

        JsonNode jsonNode = Json.buildJson()
            .addJsonLiteral("message", JsonLiteral.of( "succcess"))
            .addJsonLiteral("mes", JsonLiteral.of( "succcess"))
            .addJsonObject("map", jsonObject)
            .addJsonArray("array", jsonArray)
            .build();

        for (JsonNode node : jsonArray) {
            System.out.println(node);
        }

        //System.out.println(jsonNode.toJsonString());

        JsonNode parsedNode = Json.parseJson("{\"clusterMetrics\":{\"appsSubmitted\":2,\"appsCompleted\":0,\"appsPending\":0,\"appsRunning\":2,\"appsFailed\":0,\"appsKilled\":0,\"reservedMB\":0,\"availableMB\":10379,\"allocatedMB\":15360,\"reservedVirtualCores\":0,\"availableVirtualCores\":2,\"allocatedVirtualCores\":6,\"containersAllocated\":4,\"containersReserved\":0,\"containersPending\":0,\"totalMB\":25739,\"totalVirtualCores\":8,\"totalNodes\":1,\"lostNodes\":0,\"unhealthyNodes\":0,\"decommissioningNodes\":0,\"decommissionedNodes\":0,\"rebootedNodes\":0,\"activeNodes\":1,\"shutdownNodes\":0,\"totalUsedResourcesAcrossPartition\":{\"memory\":15360,\"vCores\":6},\"totalClusterResourcesAcrossPartition\":{\"memory\":25739,\"vCores\":8},\"totalReservedResourcesAcrossPartition\":{\"memory\":0,\"vCores\":0},\"totalAllocatedContainersAcrossPartition\":4,\"crossPartitionMetricsAvailable\":true}}");

        System.out.println(parsedNode.toJsonString(true));

    }


}
